package cn.edu.sdjzu.xg.bysj.filter;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

//@WebFilter(filterName = "Filter-1", urlPatterns = {"/*"})
public class AuthorityFilter implements Filter {
    private static final Logger log = LogManager.getLogger(AuthorityFilter.class);
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) req;

        String requestURL = httpServletRequest.getRequestURL().toString();
        log.debug("requst target is " + requestURL);
        log.debug("request method is " + httpServletRequest.getMethod());
        //do filter

        chain.doFilter(req, resp);
        log.debug("complete " + requestURL);
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
